using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;
 
public partial class JobSeekers_copyresume : System.Web.UI.Page
{
    string connectionString = "";
    string resumeID = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            connectionString =
                 WebConfigurationManager.ConnectionStrings[
                   "RecruitVietnam"].ConnectionString;
            if (Session.Contents["jsuserid"] == null)
            {
                Response.Redirect("login.aspx");
            }
            else
            {
                resumeID = Request.QueryString.Get("resumeid");
                if (!IsPostBack)
                {              
                    
                    literalResumeTitle.Text = Request.QueryString.Get("title");
                    txtTitle.Text = "Copy of "+ literalResumeTitle.Text;
                    Common cls = new Common(connectionString);
                    if (cls.CheckResume(Convert.ToString(
                    Session.Contents["jsuserid"])) >= 5)
                        btnCopy.Enabled = false;
                    else
                        btnCopy.Enabled = true;
                    
                }
            }
        }
        catch (Exception ex)
        {
            literalError.Text = ex.Message;
        }
    }
    protected void btnCopy_Click(object sender, EventArgs e)
    {
        try
        {
            SqlServerProvider cls = 
            new SqlServerProvider(connectionString);
            cls.CommandText = "SPCopyResume";
            cls.CommandType = 
            CommandType.StoredProcedure;
            cls.ParameterCollection = 
            new string[3] { "@UserID", 
            "@ResumeID", "@Title" };
            cls.ValueCollection = new 
            string[3]{Convert.ToString(
            Session.Contents["jsuserid"]), 
            resumeID, txtTitle.Text};
            if(cls.ExecuteNonQuery()>0)
                Response.Redirect("resumes.aspx");
        }
        catch(Exception ex)
        {
            literalError.Text = ex.Message;
        }
    }
    
    
}
